package com.heima.search.controller;

import com.heima.common.dtos.ResponseResult;
import com.heima.model.search.dtos.UserSearchHistoryParamDTO;
import com.heima.search.service.SearchHistoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author Fuqiang
 * @since :2023-03-31
 */
@RestController
public class SearchHistoryController {

    @Autowired
    SearchHistoryService searchHistoryService;

    /**
     * 加载关键字列表
     *
     * @return
     */
    @PostMapping("/api/v1/history/load")
    public ResponseResult<List<String>> loadHistory(@Validated @RequestBody UserSearchHistoryParamDTO dto) {
        List<String> historyList = searchHistoryService.loadHistory(dto);

        return ResponseResult.ok(historyList);
    }
}
